package com.activitycode.datamodel.model;

import org.json.*;
import java.util.ArrayList;

public class UserBase {
	
    private boolean result;
    private UserInfo userInfo;
    private ArrayList<PetInfo> petInfo;
    
    
	public UserBase () {
		
	}	
        
    public UserBase (JSONObject json) {
    
        this.result = json.optBoolean("result");
        this.userInfo = new UserInfo(json.optJSONObject("userInfo"));

        this.petInfo = new ArrayList<PetInfo>();
        JSONArray arrayPetInfo = json.optJSONArray("petInfo");
        if (null != arrayPetInfo) {
            int petInfoLength = arrayPetInfo.length();
            for (int i = 0; i < petInfoLength; i++) {
                JSONObject item = arrayPetInfo.optJSONObject(i);
                if (null != item) {
                    this.petInfo.add(new PetInfo(item));
                }
            }
        }
        else {
            JSONObject item = json.optJSONObject("petInfo");
            if (null != item) {
                this.petInfo.add(new PetInfo(item));
            }
        }


    }
    
    public boolean getResult() {
        return this.result;
    }

    public void setResult(boolean result) {
        this.result = result;
    }

    public UserInfo getUserInfo() {
        return this.userInfo;
    }

    public void setUserInfo(UserInfo userInfo) {
        this.userInfo = userInfo;
    }

    public ArrayList<PetInfo> getPetInfo() {
        return this.petInfo;
    }

    public void setPetInfo(ArrayList<PetInfo> petInfo) {
        this.petInfo = petInfo;
    }


    
}
